<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="安装操作系统的过程就是规划系统，把需要的功能和响应的文件放到合适的位置；创建用户init程序可以自动化实现 CentOS系统安装：bootloader–kernel（initrd（rootfs））–anaconda安装程序：anaconda必须先启动内核：提供一个界面。首先，创建一个bootloader（安装在光盘或者U盘）之后加载设备上某个路径的kernel（vmlinuz）之后借助于initr">
<meta property="og:type" content="article">
<meta property="og:title" content="23.anaconda配置定制自动化安装Linux">
<meta property="og:url" content="http://yoursite.com/2020/06/26/23-anaconda%E9%85%8D%E7%BD%AE%E5%AE%9A%E5%88%B6%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AE%89%E8%A3%85Linux-1/index.html">
<meta property="og:site_name" content="Lcxiao&#39;s blog">
<meta property="og:description" content="安装操作系统的过程就是规划系统，把需要的功能和响应的文件放到合适的位置；创建用户init程序可以自动化实现 CentOS系统安装：bootloader–kernel（initrd（rootfs））–anaconda安装程序：anaconda必须先启动内核：提供一个界面。首先，创建一个bootloader（安装在光盘或者U盘）之后加载设备上某个路径的kernel（vmlinuz）之后借助于initr">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-26T23:30:47.000Z">
<meta property="article:modified_time" content="2020-06-27T07:31:04.386Z">
<meta property="article:author" content="lcxiao">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2020/06/26/23-anaconda%E9%85%8D%E7%BD%AE%E5%AE%9A%E5%88%B6%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AE%89%E8%A3%85Linux-1/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>23.anaconda配置定制自动化安装Linux | Lcxiao's blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="Lcxiao's blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Lcxiao's blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-lifestyle">

    <a href="/lifestyle/" rel="section"><i class="fa fa-fw fa-lifestyle"></i>LifeStyle</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/06/26/23-anaconda%E9%85%8D%E7%BD%AE%E5%AE%9A%E5%88%B6%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AE%89%E8%A3%85Linux-1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="lcxiao">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Lcxiao's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          23.anaconda配置定制自动化安装Linux
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-06-27 07:30:47 / 修改时间：15:31:04" itemprop="dateCreated datePublished" datetime="2020-06-27T07:30:47+08:00">2020-06-27</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>安装操作系统的过程就是规划系统，把需要的功能和响应的文件放到合适的位置；<br>创建用户<br>init程序<br>可以自动化实现</p>
<p>CentOS系统安装：<br>bootloader–kernel（initrd（rootfs））–anaconda<br>安装程序：anaconda<br>必须先启动内核：<br>提供一个界面。首先，创建一个bootloader（安装在光盘或者U盘）<br>之后加载设备上某个路径的kernel（vmlinuz）<br>之后借助于initrd（rootfs）直接内存作为根文件系统；<br>之后启动anaconda程序（作为sbin/init）用户空间的第一个程序</p>
<p>anaconda两个界面<br>tui：基于cureses的文本配置窗口<br>gui：图形界面</p>
<p>CentOS的安装过程启动流程：<br>MBR：boot.cat<br>stage2：isolinux/isolinux.bin<br>    配置文件：isolinux/isolinux.cfg</p>
<p>每个对应的菜单选项：<br>    加载内核：isolinux/vmlinuz<br>    向内核传递参数：append initrd=initrd.img </p>
<p>获取根文件系统，并启动anaconda<br>    默认界面是图形界面；至少需要512MB内存，否则无法使用图形界面<br>    如果需要显示指定启动tui接口，向启动内核传递一个参数“text”即可；</p>
<pre><code>ESC：
boot：linux text</code></pre><p>注意：上述内容一般位于引导设备（光盘或者U盘）或者是网络上；<br>anaconda启动之后剩余的过程，后续的anaconda及其安装用到的程序包等；<br>可以来自于程序包仓库，此仓库的位置可以为：</p>
<ul>
<li>本地光盘</li>
<li>本地硬盘</li>
<li>ftp服务器</li>
<li>http服务器</li>
<li>nfs服务器</li>
</ul>
<p>如要手动指明安装仓库：则按ESC键<br>    boot：linux method（询问用户，让用户选择安装方法）</p>
<p>anaconda的工作过程：<br>安装前配置阶段<br>    安装过程使用的语言<br>    键盘类型<br>    安装目标存储设备<br>        Basic Storage：本地磁盘<br>        Special Storage：iscsi<br>    设定主机名<br>    配置网络接口<br>    时区<br>    管理员密码<br>    设定分区方式及MBR的安装位置；<br>    创建一个普通用户；<br>安装阶段<br>    在目标磁盘创建分区并执行格式化<br>    将选定的程序包安装至指定位置<br>    安装bootloader<br>首次启动<br>    iptables<br>    selinux<br>    core dump（核心转储，崩溃时，把内存数据备份下来）（可做分析用）（内存小于2G无法开启）</p>
<p>anaconda配置方式<br>    1. 交互式配置方式<br>    2. 支持通过读取配置文件中实现定义好的配置项自动完成配置；遵循特定的语法格式，此文件即为kickstart文件；</p>
<p>此文件可以放在本地文件服务器上；</p>
<p>安装引导选项：<br>text：文本安装方式<br>method：手动指定使用的安装方法<br>与网路相关的引导选项：<br>    ip=IPADDR<br>    netmask=NETMASK<br>    gateway=GW<br>    dns=DNS_SERVER_IP<br>远程访问功能相关的引导选项：<br>    VNC<br>    vncpasswd=’password’<br>启动紧急救援模式：<br>    rescue<br>装载额外驱动：<br>    dd</p>
<p><a href="http://www.redhat.com/docs" target="_blank" rel="noopener">www.redhat.com/docs</a> 《installation guide》</p>
<h2 id="CentOS系统安装："><a href="#CentOS系统安装：" class="headerlink" title="CentOS系统安装："></a>CentOS系统安装：</h2><pre><code>ks：指明kickstart文件的位置
ks=
    DVD driver：ks=cdrom:PATH/TO/KICKSTART_FILE
    Hard_Driver:ks=hd:/DEVICE/PATH/TO/KICKSTART_FILE
    HTTP Server  ks=http://HOST[:PORT]/PATH/TO/KICKSTART_FILE
    FTP Server ks=ftp://HOST[:PORT]/PATH/TO/KICKSTART_FILE
    HTTPS Server: ks=https://HOST[:PORT]/PATH/TO/KICKSTART_FILE

kickstart文件的格式
    命令段  指定各种安装前配置选项，如键盘类型等；
        必备命令
        可选命令

    程序包段    
        指明要安装的程序包，以及包组，也包括不安装的程序包；
        %packages 表示程序包段开始，中间的都表示程序包
        @group_name 安装包组
        package 安装
        -package    不安装
        %end        结束

    脚本段
        %pre 安装前脚本
            运行环境：运行安装介质上的微型linux系统环境
        %post 安装后脚本
            运行环境：安装完成的系统</code></pre><h3 id="命令端中的选项"><a href="#命令端中的选项" class="headerlink" title="命令端中的选项"></a>命令端中的选项</h3><p>auth | authconfig   认证方式配置<br><code>auth --enableshadow --passalgo=sha512</code><br>bootloader  定义bootloader的安装位置及相关配置<br><code>bootloader --append=&quot; crashkernel=auto&quot; --location=mbr --boot-drive=sda</code><br>Keyboard layouts    设置键盘类型<br><code>keyboard --vckeymap=us --xlayouts=&#39;us&#39;</code><br>System language 语言类型<br><code>lang en_US.UTF-8</code><br>part    分区布局</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">   </span><br><span class="line"># Disk partitioning information</span><br><span class="line">part &#x2F;boot --fstype&#x3D;&quot;xfs&quot; --ondisk&#x3D;sda --size&#x3D;1024</span><br><span class="line">part &#x2F; --fstype&#x3D;&quot;xfs&quot; --ondisk&#x3D;sda --size&#x3D;17404</span><br><span class="line">part swap --fstype&#x3D;&quot;swap&quot; --ondisk&#x3D;sda --size&#x3D;204</span><br></pre></td></tr></table></figure>
<p> Partition clearing information 清空磁盘分区<br>    clearpart –none –initlabel</p>
<p>volgroup：创建卷组<br>logvol：</p>
<p>Root password       设置密码：<br>rootpw –iscrypted $6$TWt34GTGFsaxobTC$cR4TOgqr/2uf7RDAPFlPT6QgPbhoMZVNsKMAKpk3FduEsGB4F92Gx8Vivm.26QdEnnGlCUcbMWHQYqoA8QPnz.</p>
<p>使用openssl手动生成一个：$ openssl passwd -1 -salt <code>openssl rand -hex 4</code></p>
<p>System timezone 时区<br>timezone Asia/Shanghai –isUtc –nontp</p>
<h3 id="可选命令："><a href="#可选命令：" class="headerlink" title="可选命令："></a>可选命令：</h3><p>install OR upgrade ：安装或升级<br>text ：安装界面类型 text为tui ，默认为GUI<br>network ：配置网络接口<br>    network –onboot=yes –device eth0 –bootproto dhcp –noipv6<br>firewall： 防火墙<br>    firewall –disable<br>selinux ：SELinux<br>    selinux –disable</p>
<p>系统安装之后禁用防火墙：<br>    CentOS6：<br>        service iptables off<br>        chkconfig iptables off<br>    CentOS7：<br>        systemctl stop firewalld<br>        systemctl disable firewalls</p>
<p>系统安装之后禁用selinux<br>    /etc/sysconfig/selinux 修改SELINUX的值为下面2.3项即可<br>        enforcing<br>        permissive<br>        disable<br>    getenforce  获取状态<br>    setenforce 0 设置关闭，立即生效<br>编辑/etx/sysconfig/selinux 或者 /etc/selinux/config</p>
<p>halt、poweroff 或者reboot 安装完成之后的行为：<br>repo：指定安装时使用的repository：<br>    repo –name=”CentOS” –baseurl=cdrom:sr0 –cost=100<br>url:指明安装时使用的repository，但为url格式：<br>url –url=<a href="http://xxxx" target="_blank" rel="noopener">http://xxxx</a><br>必须定义好网络，能够访问才行；</p>
<p>其他可参考官方文档：《Installation Guide》</p>
<h3 id="如何编辑anaconda-ks-cfg文件"><a href="#如何编辑anaconda-ks-cfg文件" class="headerlink" title="如何编辑anaconda-ks.cfg文件"></a>如何编辑anaconda-ks.cfg文件</h3><p>yum install system-config-kickstart包</p>
<p>ESC<br>linux ip=xxx.xxx.xxx.xxx netmask=255.255.255.xxx ks=<a href="http://PATH/to/file" target="_blank" rel="noopener">http://PATH/to/file</a></p>
<p>把光盘的isolinux文件夹拷贝过来<br>把ks文件复制过来<br>放在光盘根目录或者isolinux文件夹下都可以<br>创建光盘镜像<br>mkisofs -R -J -T -v –no-emul-boot –boot-load-size 4 –boot-info-table -V “光盘名字” -c isolinux/boot.cat -b isolinux/isolinux.bin -o /root/boot.iso myboot/</p>
<p>网络启动<br>dhcp服务器<br>tftp服务器<br>网络仓库</p>
<p>自动化安装过程<br>DVD ： ks=cdrom：/PATH/TO/KS_FILE<br>HTTP: ks=<a href="http://HOST:PORT/PATH/TO/KS_FILE">http://HOST:PORT/PATH/TO/KS_FILE</a></p>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/06/22/2-24%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85/" rel="prev" title="2.24编译安装">
      <i class="fa fa-chevron-left"></i> 2.24编译安装
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/06/26/24-%E5%BE%AA%E7%8E%AF%E7%9A%84%E9%AB%98%E7%BA%A7%E7%94%A8%E6%B3%95/" rel="next" title="24.循环的高级用法">
      24.循环的高级用法 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#CentOS系统安装："><span class="nav-number">1.</span> <span class="nav-text">CentOS系统安装：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#命令端中的选项"><span class="nav-number">1.1.</span> <span class="nav-text">命令端中的选项</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#可选命令："><span class="nav-number">1.2.</span> <span class="nav-text">可选命令：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#如何编辑anaconda-ks-cfg文件"><span class="nav-number">1.3.</span> <span class="nav-text">如何编辑anaconda-ks.cfg文件</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">lcxiao</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://163.com/" title="http:&#x2F;&#x2F;163.com" rel="noopener" target="_blank">163</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="http://baidu.com/" title="http:&#x2F;&#x2F;baidu.com" rel="noopener" target="_blank">baidu</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="/dalipan.com" title="dalipan.com">dalipan</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://google.com/" title="https:&#x2F;&#x2F;google.com" rel="noopener" target="_blank">Google</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">lcxiao</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
